package com.sbm.quartz;

import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.fastjson.JSON;
import com.sbm.svc.TestService;

public class TestJob implements Job {
    private static final Logger LOGGER = LoggerFactory.getLogger(TestJob.class);

    @Autowired
    private TestService testService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        LOGGER.info("QuartzJob：" + JSON.toJSONString(context.getJobDetail().getKey()));
        LOGGER.info(context.getJobDetail().getDescription());
        LOGGER.info(JSON.toJSONString(context.getJobDetail().getJobDataMap()));
        if (context.getTrigger().getStartTime() != null)
            LOGGER.info(context.getTrigger().getStartTime().toString());
        if (context.getTrigger().getEndTime() != null)
            LOGGER.info(context.getTrigger().getEndTime().toString());
        LOGGER.info(JSON.toJSONString(testService.select()));
    }
}
